#ifndef __GLOBAL_H
#define __GLOBAL_H

#include "cms8s6990.h"
#include <string.h>
#include "wdt.h"



//ￄ1�71ￄ1�77ￄ1�77ￄ1�79ￄ1�71ￄ1�77ￄ1�71ￄ1�77****************************************************
#define  unchar     	unsigned char 
#define  unint        	unsigned int
#define  unlong     	unsigned long
typedef	unsigned char	uint8;
#define uchar 			unsigned char
#define INT8U   		uint8
typedef	volatile unsigned char vuint8;
typedef	char			int8;
typedef	volatile char	vint8;
typedef	unsigned int	uint16;
typedef	volatile unsigned int	vuint16;
typedef	int				int16;
typedef volatile int	vint16;
typedef long		int32;
typedef unsigned long uint32;

#define		YES		1
#define		NO		0

#define		HIGH	1
#define		LOW		0

//#define		TRUE	1
//#define		FALSE	0

#define		SET		1
#define		RESET	0

#ifndef NULL
#define		NULL	0
#endif

#ifdef	_GLOBAL_VAR_
#define	EXTERN
#else
#define	EXTERN	extern
#endif

#ifdef _USE_XDATA_
#define XDATA   xdata
#else
#define XDATA
#endif

//#define DEBUG_MODE
#define _nop2_()	_nop_(),_nop_()
#define _nop3_()	_nop_(),_nop2_()
#define _nop4_()	_nop_(),_nop3_()
#define _nop5_()	_nop_(),_nop4_()
#define _nop6_()	_nop_(),_nop5_()

#define __NOP()			_nop_()

#define clrwdt()		TA=0xAA,TA=0x55,WDCON=0x01;

#define software_rst_system()	TA=0xAA,TA=0x55,WDCON=0x80;

#define idle()				_nop6_(),PCON=PCON|0x01,_nop6_()
#define sleep()				_nop6_(),PCON=PCON|0x06,_nop6_()
#define stop()				_nop6_(),PCON=PCON|0x06,_nop6_()
#define stop_forever()		_nop6_(),PCON=PCON|0x02,_nop6_()


#define CLRWDT()  WDT_ClearWDT()    //clrwdt()
#define EN_WDT()	(WDCON |= 0x02)
#define DIS_WDT()	(WDCON &= (~0x02))

#define DEF_PIN(PORT,PIN)       PORT##PIN
#define DEF_TRIS(PORT)          PORT##TRIS
#define DEF_UP(PORT)            PORT##UP
#define DEF_GPIO(PIN)           GPIO_PIN_##PIN

EXTERN u8 g_nSysTickCount;
// EXTERN u8 ID[3];
EXTERN vuint16 TmDelayMs;
EXTERN vuint8 CntTimeBase4ms;
EXTERN vuint8 CntTimeBase10ms;
EXTERN vuint8 CntTimeFlash;
EXTERN volatile f_Flash;
// EXTERN bit f_WorkMode_Pair;
EXTERN uint8 WorkMode;
EXTERN uint16 CntDelayToSleep;
EXTERN uint8 BatV;
EXTERN bit f_Low_Power;
EXTERN uint8 FlashTime;
// EXTERN uint8 TouchKey;
#ifndef _DEBUG_EN_
#define _DEBUG_EN_  (0)
#endif

#endif
